<div class="row">
  <div class="panel panel-default">
    <div class="panel-heading panel-title" data-toggle="collapse" data-target="#features" >
      Features <span class="glyphicon glyphicon-menu-down"></span>
    </div>
    <div id="features" class="panel-body collapse">
      <span class="button-bar">
        <%= build_page(cuke_sniffer, "expand_and_collapse_buttons.html.erb") %>
      </span>
      <% if cuke_sniffer.features.count == 0 %>
          <div>
            <div>There were no Features to sniff in '<%= cuke_sniffer.features_location %>'!</div>
          </div>
      <% elsif cuke_sniffer.features.count >= 1 && cuke_sniffer.scenarios.count >=1 && cuke_sniffer.summary[:features][:total_score] ==0 && cuke_sniffer.summary[:scenarios][:total_score] ==0 %>
          <div>
            <div>Excellent! No smells found for Features and Scenarios!</div>
          </div>
      <% end %>
      <% cuke_sniffer.features.each do |feature| %>
          <% next if feature.total_score == 0 %>
          <div class="feature">
            <div class="row">
              <div class="col-md-12 title">
                <div class="col-md-1 red" title="Total Score from this Feature.">
                  <%= feature.total_score %>
                </div>
                <div class="col-md-11">
                    <% if feature.name.to_s.empty? %>
                        No Feature Description
                    <% else %>
                        <%= feature.name %>
                    <% end %>
                </div>
              </div>
              <div class="details col-md-12" style="display:none;">
                <div class="well">
                  <div class="row">
                    <div class="col-md-12 filename">
                      File: <a target="_blank" href="file:///<%= feature.location.gsub(/:\d+$/, "") %>" title="Note: Links to file on system this report was generated.">
                        <%= feature.location.gsub(cuke_sniffer.features_location, '') %>
                      </a>
                    </div>
                  </div>

                  <div class="row featureProblems">
                    <div class="col-md-12">
                      <h4>
                        Feature:
                        <span class="red" title="Points earned from just the feature. This updates based on what rules
                        are active." data-total-feature-score="<%=feature.score %>">
                          <%= feature.score %>
                        </span>
                      </h4>
                    </div>
                    <% SummaryHelper::sort_improvement_list(feature.rules_hash).each do |phrase, count| %>
                        <div data-improvement-row>
                          <div class="col-md-1 red" data-score>
                            <%= count %>
                          </div>
                          <div class="col-md-11" data-improvement="<%=phrase %>">
                            <%= phrase %>
                          </div>
                        </div>
                    <% end %>
                  </div>

                  <div class="row backgroundProblems">
                    <% unless feature.background.nil? %>
                        <div class="col-md-12">
                          <h4>
                            Background:
                            <span class="red" title="Points earned from just the background. This updates based on what
                            rules are active." data-total-feature-score="<%=feature.background.score %>">
                              <%= feature.background.score %>
                            </span>
                          </h4>
                        </div>
                        <% SummaryHelper::sort_improvement_list(feature.background.rules_hash).each do |phrase, count| %>
                            <div data-improvement-row>
                              <div class="col-md-1 red" data-score>
                                <%= count %>
                              </div>
                              <div class="col-md-11" data-improvement="<%=phrase %>">
                                <%= phrase %>
                              </div>
                            </div>
                        <% end %>
                    <% end %>
                  </div>
                  <div class="row scenarios">
                    <div class="col-md-12">
                      <h4>Scenarios:
                        <span class="red" title="Total Points earned from all the scenarios in this feature. This updates
                        based on what rules are active." data-total-scenarios-score="<%=feature.scenarios_score%>">
                          <%= feature.scenarios_score %>
                        </span>
                      </h4>
                    </div>
                    <div class="col-md-12 scenarios">
                      <% feature.scenarios.each do |scenario| %>
                        <% next if scenario.score == 0 %>
                        <div class="col-md-12 scenario">
                          <div class="col-md-12 title">
                            <div class="btn btn-xs btn-default" style="display:none;"> <!--TODO enable this feature -->
                              View <span class="glyphicon glyphicon-eye-open"></span>
                            </div>
                            <%= scenario.type %>: <%=scenario.name %>
                          </div>
                          <div class="col-md-12 details well">
                            <% SummaryHelper::sort_improvement_list(scenario.rules_hash).each do |phrase, count| %>
                              <div class="row" data-improvement-row>
                                <div class="col-md-1 red" data-score>
                                  <%= count %>
                                </div>
                                <div class="col-md-11" data-improvement="<%=phrase %>">
                                  <%= phrase %>
                                </div>
                              </div>
                            <% end %>
                          </div>
                        </div>
                      <% end %>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
      <% end %>
    </div>
  </div>
</div>